```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MyBatis 全面解析 - 现代Java持久层框架</title>
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: #333;
            line-height: 1.6;
            background-color: #f8fafc;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #1a1a1a;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 8px;
            overflow: hidden;
        }
        .code-header {
            background-color: #1e1e1e;
            padding: 0.5rem 1rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .nav-link {
            position: relative;
        }
        .nav-link::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 0;
            height: 2px;
            background-color: #667eea;
            transition: width 0.3s ease;
        }
        .nav-link:hover::after {
            width: 100%;
        }
        .timeline-item {
            position: relative;
            padding-left: 2rem;
            margin-bottom: 2rem;
        }
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #667eea;
            border: 3px solid white;
            box-shadow: 0 0 0 2px #667eea;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .concept-map {
            background-color: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 animate-fade-in-down">MyBatis 全面解析</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto">灵活高效的Java持久层框架，简化数据库操作</p>
            <div class="flex justify-center space-x-4">
                <a href="#introduction" class="bg-white text-indigo-700 px-6 py-3 rounded-full font-medium hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#quick-start" class="bg-indigo-600 text-white px-6 py-3 rounded-full font-medium hover:bg-indigo-700 transition duration-300">
                    <i class="fas fa-rocket mr-2"></i>快速开始
                </a>
            </div>
        </div>
    </section>

    <!-- Navigation -->
    <nav class="bg-white shadow-sm sticky top-0 z-10">
        <div class="container mx-auto px-4">
            <div class="flex justify-center space-x-8 py-4">
                <a href="#introduction" class="nav-link text-gray-700 hover:text-indigo-600">简介</a>
                <a href="#features" class="nav-link text-gray-700 hover:text-indigo-600">特性</a>
                <a href="#quick-start" class="nav-link text-gray-700 hover:text-indigo-600">快速开始</a>
                <a href="#orm" class="nav-link text-gray-700 hover:text-indigo-600">ORM映射</a>
                <a href="#advanced" class="nav-link text-gray-700 hover:text-indigo-600">高级特性</a>
                <a href="#spring-integration" class="nav-link text-gray-700 hover:text-indigo-600">Spring整合</a>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto px-4 py-12 max-w-5xl">
        <!-- Introduction Section -->
        <section id="introduction" class="mb-20">
            <div class="flex flex-col md:flex-row gap-8 items-center">
                <div class="md:w-1/2">
                    <h2 class="text-3xl font-bold mb-6">MyBatis 简介</h2>
                    <p class="text-lg mb-4">MyBatis是一个半ORM（对象关系映射）框架，它内部封装了JDBC，允许开发者通过XML或注解直接编写原生态SQL语句，从而避免了几乎所有的JDBC代码和手动设置参数以及获取结果集的工作。</p>
                    <p class="text-lg mb-6">MyBatis支持自定义SQL、存储过程以及高级映射，使得复杂的查询和数据库操作变得十分灵活。</p>
                    <div class="bg-indigo-50 border-l-4 border-indigo-500 p-4">
                        <p class="text-indigo-700"><i class="fas fa-info-circle mr-2"></i>MyBatis的前身是iBATIS，由Clinton Begin在2001年发起的一个开源项目，最初侧重于密码软件的开发。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <img src="https://cdn.nlark.com/yuque/0/2024/jpeg/21449790/1715914633998-83d7b8ad-cdb0-4207-a5f6-04b8b5f99162.jpeg" alt="MyBatis架构图" class="rounded-lg shadow-lg w-full">
                </div>
            </div>
        </section>

        <!-- What is ORM Section -->
        <section id="orm" class="mb-20">
            <h2 class="text-3xl font-bold mb-6">什么是ORM</h2>
            <div class="bg-white rounded-lg shadow-md p-6 mb-8">
                <p class="text-lg mb-4"><strong>ORM框架是一种编程技术，它建立了面向对象编程语言中的对象与关系型数据库中的数据表之间的映射关系。</strong></p>
                <p class="mb-4">这种映射允许开发者使用对象而不是传统的SQL语句来管理数据库，从而简化了数据访问和操作的复杂性。</p>
                <div class="flex flex-col md:flex-row gap-8 mt-6">
                    <div class="md:w-1/2">
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="text-xl font-semibold mb-3 text-indigo-600"><i class="fas fa-check-circle mr-2"></i>ORM优势</h4>
                            <ul class="space-y-2">
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>提高开发效率</li>
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>代码更加直观和易于维护</li>
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>自动生成SQL语句</li>
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>提供事务管理、缓存优化等功能</li>
                            </ul>
                        </div>
                    </div>
                    <div class="md:w-1/2">
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="text-xl font-semibold mb-3 text-indigo-600"><i class="fas fa-exclamation-circle mr-2"></i>ORM局限性</h4>
                            <ul class="space-y-2">
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>复杂查询可能效率较低</li>
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>学习曲线可能较陡</li>
                                <li><i class="fas fa-angle-right text-indigo-500 mr-2"></i>对数据库特有功能支持有限</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1715914662366-12edbd3e-e165-45ce-bfa8-d8e484150cad.png" alt="ORM映射示意图" class="rounded-lg shadow-md w-full">
                </div>
                <div class="concept-map">
                    <div class="mermaid">
                        graph TD
                            A[应用程序] -->|操作| B[Java对象]
                            B -->|ORM映射| C[数据库表]
                            C -->|SQL生成| D[数据库]
                            D -->|结果集| C
                            C -->|结果映射| B
                            B -->|业务处理| A
                    </div>
                </div>
            </div>
        </section>

        <!-- Features Section -->
        <section id="features" class="mb-20">
            <h2 class="text-3xl font-bold mb-8">MyBatis的优势和适用场景</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <div class="feature-card bg-white p-6 rounded-lg shadow-md transition duration-300">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-sliders-h"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">核心优势</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>灵活性：直接编写原生SQL，精确控制数据库操作</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>代码简洁：相比JDBC显著减少代码量</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>易于管理：SQL与代码解耦，便于统一管理</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>动态SQL：支持动态构建SQL语句</span>
                        </li>
                    </ul>
                </div>
                <div class="feature-card bg-white p-6 rounded-lg shadow-md transition duration-300">
                    <div class="text-indigo-600 text-3xl mb-4">
                        <i class="fas fa-laptop-code"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">适用场景</h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-globe text-blue-500 mt-1 mr-2"></i>
                            <span>Web开发：快速实现CRUD操作，处理复杂关联查询</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-database text-blue-500 mt-1 mr-2"></i>
                            <span>大数据处理：优化数据处理流程，提高性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-chart-line text-blue-500 mt-1 mr-2"></i>
                            <span>数据分析：编写特定查询获取所需数据</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-project-diagram text-blue-500 mt-1 mr-2"></i>
                            <span>复杂业务系统：需要灵活SQL控制的项目</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Quick Start Section -->
        <section id="quick-start" class="mb-20">
            <h2 class="text-3xl font-bold mb-8">快速开始</h2>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">1. 引入依赖</h3>
                <div class="code-block">
                    <div class="code-header text-gray-300">
                        <span>pom.xml</span>
                        <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;dependency&gt;
    &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
    &lt;artifactId&gt;mybatis&lt;/artifactId&gt;
    &lt;version&gt;3.4.6&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    &lt;version&gt;5.1.47&lt;/version&gt;
&lt;/dependency&gt;
                    </code></pre>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">2. 创建MyBatis配置文件</h3>
                <div class="code-block">
                    <div class="code-header text-gray-300">
                        <span>mybatis.xml</span>
                        <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd"&gt;

&lt;configuration&gt;
    &lt;environments default="MySqlDB"&gt;
        &lt;environment id="MySqlDB"&gt;
            &lt;transactionManager type="JDBC"/&gt;
            &lt;dataSource type="org.apache.ibatis.datasource.pooled.PooledDataSourceFactory"&gt;
                &lt;property name="driver" value="com.mysql.jdbc.Driver"/&gt;
                &lt;property name="url" value="jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8"/&gt;
                &lt;property name="username" value="root"/&gt;
                &lt;property name="password" value="root"/&gt;
            &lt;/dataSource&gt;
        &lt;/environment&gt;
    &lt;/environments&gt;

    &lt;mappers&gt;
        &lt;mapper resource="mapper/UserMapper.xml"/&gt;
    &lt;/mappers&gt;
&lt;/configuration&gt;
                    </code></pre>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">3. 定义实体类和Mapper</h3>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <div class="code-block h-full">
                            <div class="code-header text-gray-300">
                                <span>User.java</span>
                                <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                                    <i class="far fa-copy mr-1"></i>复制
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">
@Data
public class User {
    private Integer id;
    private String name;
    private String password;
    private String sex;
}
                            </code></pre>
                        </div>
                    </div>
                    <div>
                        <div class="code-block h-full">
                            <div class="code-header text-gray-300">
                                <span>UserMapper.java</span>
                                <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                                    <i class="far fa-copy mr-1"></i>复制
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">
public interface UserMapper {
    public Integer save(User user);
}
                            </code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">4. 创建Mapper.xml文件</h3>
                <div class="code-block">
                    <div class="code-header text-gray-300">
                        <span>UserMapper.xml</span>
                        <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;

&lt;mapper namespace="com.ts.mybatis.UserMapper"&gt;
    &lt;insert id="save" &gt;
        insert into t_user (username) values(#{username})
    &lt;/insert&gt;
&lt;/mapper&gt;
                    </code></pre>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold mb-6">5. 测试</h3>
                <div class="code-block">
                    <div class="code-header text-gray-300">
                        <span>MyBatisTest.java</span>
                        <button class="text-sm bg-gray-700 px-2 py-1 rounded hover:bg-gray-600">
                            <i class="far fa-copy mr-1"></i>复制
                        </button>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-java">
@Test
public void test1() throws Exception {
    //1.获得读取MyBatis配置文件的流对象
    InputStream is = Resources.getResourceAsStream("mybatis.xml");

    //2.构建SqlSession连接对象的工厂
    SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);

    //3.通过工厂获得连接对象
    SqlSession sqlSession = factory.openSession();

    //4.通过连接对象获得接口实现类对象
    UserMapper userMapper= sqlSession.getMapper(UserMapper.class);

    //5.调用接口中的方法
    User user = new User();
    user.setUsername("toString");
    Integer save = userMapper.save(user);
    System.out.println(save);

    //6.事务提交
    sqlSession.commit();
}
                    </code></pre>
                </div>
            </div>
        </section>

        <!-- CRUD Section -->
        <section id="crud" class="mb-20">
            <h2 class="text-3xl font-bold mb-8">MyBatis的CRUD操作</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 text-indigo-600">查询</h3>
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.java</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-java">
public interface UserMapper {
    public User selectUserById(Integer id);
}
                        </code></pre>
                    </div>
                    <div class="code-block mt-4">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;select id="selectUserById" resultType="user"&gt;
    SELECT * FROM t_users WHERE id = #{id}
&lt;/select&gt;
                        </code></pre>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 text-indigo-600">删除</h3>
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.java</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-java">
public interface UserMapper {
    public User deleteUserById(Integer id);
}
                        </code></pre>
                    </div>
                    <div class="code-block mt-4">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;delete id="deleteUserById" parameterType="int"&gt;
    DELETE FROM t_users WHERE id = #{id} 
&lt;/delete&gt;
                        </code></pre>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 text-indigo-600">修改</h3>
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.java</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-java">
public interface UserMapper {
    public User updateUser(User user);
}
                        </code></pre>
                    </div>
                    <div class="code-block mt-4">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;update id="updateUser" &gt;
    update t_users set username = #{username} WHERE id = #{id} 
&lt;/update&gt;
                        </code></pre>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold mb-4 text-indigo-600">添加</h3>
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.java</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-java">
public interface UserMapper {
    public Integer save(User user);
}
                        </code></pre>
                    </div>
                    <div class="code-block mt-4">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;insert id="save" &gt;
    insert into t_user (username) values(#{username})
&lt;/insert&gt;
                        </code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Advanced Features Section -->
        <section id="advanced" class="mb-20">
            <h2 class="text-3xl font-bold mb-8">高级特性</h2>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">动态SQL</h3>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <p class="mb-4">MyBatis提供了强大的动态SQL功能，可以根据不同条件生成不同的SQL语句：</p>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600"><i class="fas fa-code mr-2"></i>if标签</h4>
                            <div class="code-block">
                                <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;select id="findUsers" resultType="user"&gt;
    SELECT * FROM users
    &lt;where&gt;
        &lt;if test="name != null"&gt;
            AND name = #{name}
        &lt;/if&gt;
        &lt;if test="age != null"&gt;
            AND age = #{age}
        &lt;/if&gt;
    &lt;/where&gt;
&lt;/select&gt;
                                </code></pre>
                            </div>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600"><i class="fas fa-random mr-2"></i>choose/when/otherwise</h4>
                            <div class="code-block">
                                <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;select id="findActiveUser" resultType="user"&gt;
    SELECT * FROM users
    WHERE state = 'ACTIVE'
    &lt;choose&gt;
        &lt;when test="name != null"&gt;
            AND name = #{name}
        &lt;/when&gt;
        &lt;when test="age != null"&gt;
            AND age = #{age}
        &lt;/when&gt;
        &lt;otherwise&gt;
            AND sex = 'M'
        &lt;/otherwise&gt;
    &lt;/choose&gt;
&lt;/select&gt;
                                </code></pre>
                            </div>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600"><i class="fas fa-list-ol mr-2"></i>foreach标签</h4>
                            <div class="code-block">
                                <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;select id="selectUsersByIds" resultType="user"&gt;
    SELECT * FROM users
    WHERE id IN
    &lt;foreach item="id" collection="list" 
             open="(" separator="," close=")"&gt;
        #{id}
    &lt;/foreach&gt;
&lt;/select&gt;
                                </code></pre>
                            </div>
                        </div>
                        <div>
                            <h4 class="text-lg font-medium mb-3 text-indigo-600"><i class="fas fa-wrench mr-2"></i>set标签</h4>
                            <div class="code-block">
                                <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;update id="updateUser"&gt;
    UPDATE users
    &lt;set&gt;
        &lt;if test="name != null"&gt;name=#{name},&lt;/if&gt;
        &lt;if test="age != null"&gt;age=#{age},&lt;/if&gt;
    &lt;/set&gt;
    WHERE id=#{id}
&lt;/update&gt;
                                </code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6">缓存机制</h3>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                    <div>
                        <div class="bg-white p-6 rounded-lg shadow-md h-full">
                            <h4 class="text-xl font-semibold mb-4 text-indigo-600">一级缓存</h4>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>SqlSession级别缓存，默认开启</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>同一个SqlSession中有效</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>执行增删改操作会清空缓存</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>SqlSession关闭后缓存失效</span>
                                </li>
                            </ul>
                            <div class="mt-6">
                                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1715844248293-68b4660f-d431-4bf8-872c-33b12bc76cfe.png" alt="一级缓存示意图" class="rounded-lg shadow-sm w-full">
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="bg-white p-6 rounded-lg shadow-md h-full">
                            <h4 class="text-xl font-semibold mb-4 text-indigo-600">二级缓存</h4>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>Mapper(namespace)级别缓存，需要配置开启</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>多个SqlSession共享</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>执行增删改操作会清空缓存</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-circle text-xs mt-2 mr-2 text-indigo-500"></i>
                                    <span>支持自定义缓存实现</span>
                                </li>
                            </ul>
                            <div class="mt-6">
                                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1715844269954-3db0cc9f-88ff-45b7-97db-ba9531cd41cd.png" alt="二级缓存示意图" class="rounded-lg shadow-sm w-full">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="mt-6 bg-white p-6 rounded-lg shadow-md">
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>mybatis-config.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;settings&gt;
    &lt;setting name="cacheEnabled" value="true"/&gt;
&lt;/settings&gt;
                        </code></pre>
                    </div>
                    <div class="code-block mt-4">
                        <div class="code-header text-gray-300">
                            <span>Mapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;mapper namespace="com.ts.mapper.UserMapper"&gt;
    &lt;cache eviction="FIFO" flushInterval="60000" size="512" readOnly="true"/&gt;
    ...
&lt;/mapper&gt;
                        </code></pre>
                    </div>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold mb-6">主键回填</h3>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <p class="mb-4">在数据插入操作后，自动获取数据库生成的主键值：</p>
                    <div class="code-block">
                        <div class="code-header text-gray-300">
                            <span>UserMapper.xml</span>
                        </div>
                        <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;insert id="addUser"
        useGeneratedKeys="true"
        keyProperty="id"&gt;
    INSERT INTO t_user(username,password,age,email,sex)
    VALUES (#{username},#{password},#{age},#{email},#{sex});
&lt;/insert&gt;
                        </code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Spring Integration Section -->
        <section id="spring-integration" class="mb-20">
            <h2 class="text-3xl font-bold mb-8">Spring整合MyBatis</h2>
            <div class="bg-white p-6 rounded-lg shadow-md">
                <p class="mb-6 text-lg">Spring与MyBatis的整合是现代Java应用程序开发的常见选择。Spring提供了依赖注入、AOP等丰富的特性，而MyBatis则提供了简单灵活的ORM解决方案。将这两者整合起来，可以充分发挥它们各自的优势。</p>
                
                <h3 class="text-2xl font-semibold mb-6">1. 引入依赖</h3>
                <div class="code-block mb-8">
                    <div class="code-header text-gray-300">
                        <span>pom.xml</span>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;dependency&gt;
    &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
    &lt;artifactId&gt;mybatis&lt;/artifactId&gt;
    &lt;version&gt;3.5.10&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    &lt;version&gt;5.1.48&lt;/version&gt;
&lt;/dependency&gt;

&lt;dependency&gt;
    &lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt;
    &lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt;
    &lt;version&gt;2.2.0&lt;/version&gt;
&lt;/dependency&gt;
                    </code></pre>
                </div>
                
                <h3 class="text-2xl font-semibold mb-6">2. Spring配置</h3>
                <div class="code-block mb-8">
                    <div class="code-header text-gray-300">
                        <span>applicationContext.xml</span>
                    </div>
                    <pre class="p-4 overflow-x-auto"><code class="language-xml">
&lt;!-- 加载属性文件 --&gt;
&lt;context:property-placeholder location="classpath:jdbc.properties"/&gt;

&lt;!-- 创建数据源--&gt;
&lt;bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"&gt;
    &lt;property name="username" value="${jdbc.username}"/&gt;
    &lt;property name="password" value="${jdbc.password}"/&gt;
    &lt;property name="driverClassName" value="${jdbc.driver}"/&gt;
    &lt;property name="url" value="${jdbc.url}"/&gt;
&lt;/bean&gt;

&lt;!-- 配置SqlSessionFactory --&gt;
&lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="configLocation" value="classpath:mybatis.xml" /&gt;
&lt;/bean&gt;

&lt;!-- 配置Mapper扫描 --&gt;
&lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
    &lt;property name="basePackage" value="com.ts.mapper" /&gt;
&lt;/bean&gt;
                    </code></pre>
                </div>
                
                <h3 class="text-2xl font-semibold mb-6">3. 使用注解方式</h3>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <div class="code-block h-full">
                            <div class="code-header text-gray-300">
                                <span>UserMapper.java</span>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">
@Mapper
public interface UserMapper {
    @Select("SELECT * FROM users WHERE id = #{id}")
    User selectUserById(Integer id);
    
    @Insert("INSERT INTO users(name,age) VALUES(#{name},#{age})")
    @Options(useGeneratedKeys=true, keyProperty="id")
    int insertUser(User user);
    
    @Update("UPDATE users SET name=#{name}, age=#{age} WHERE id=#{id}")
    int updateUser(User user);
    
    @Delete("DELETE FROM users WHERE id=#{id}")
    int deleteUser(Integer id);
}
                            </code></pre>
                        </div>
                    </div>
                    <div>
                        <div class="code-block h-full">
                            <div class="code-header text-gray-300">
                                <span>UserService.java</span>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    
    public User getUserById(Integer id) {
        return userMapper.selectUserById(id);
    }
    
    @Transactional
    public void saveUser(User user) {
        userMapper.insertUser(user);
    }
}
                            </code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <script>
        // 初始化Mermaid图表
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 复制代码功能
        document.querySelectorAll('.code-header button').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.parentElement.nextElementSibling;
                const code = codeBlock.querySelector('code').textContent;
                navigator.clipboard.writeText(code).then(() => {
                    const originalText = button.innerHTML;
                    button.innerHTML = '<i class="fas fa-check mr-1"></i>已复制';
                    setTimeout(() => {
                        button.innerHTML = originalText;
                    }, 2000);
                });
            });
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```